<admintpl file="header" />
<style type="text/css">
    body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
</style>
</head>

<body>
<div id="allmap">

</div>

<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=OkM4ci06ibVrimvizgsIWv0sjASIa7BK&s=1"></script>
<script type="text/javascript" src="https://api.map.baidu.com/library/DistanceTool/1.2/src/DistanceTool_min.js"></script>
<script type="text/javascript">


    // 百度地图API功能
    var map = new BMap.Map("allmap");
    var point = new BMap.Point(113.65,34.76);
    map.centerAndZoom(point, 13);
    map.disableDoubleClickZoom(true);
    map.enableScrollWheelZoom(); //启用滚轮放大缩小，默认禁用
    map.enableContinuousZoom();

    var myIcon1 = new BMap.Icon("__PUBLIC__/images/pn.png", new BMap.Size(35, 35));

    pnRobRouteCounts();
    function pnRobRouteCounts() {
        $.ajax({
            type: "GET",
            async: true,
            url: "{:U('allpnroute')}",
            dataType: "json",
            success: function(data) {
//                console.log(data);
                map.clearOverlays();
                for (var i = 0; i < data.length; i ++) {
                    var point = new BMap.Point(data[i].longitude, data[i].latitude);
                    var content = data[i]['dispatch_name']+","+data[i]['mobile']+"</br>位置时间："+data[i]['place_up_time'];
                    var marker = new BMap.Marker(point, {icon: myIcon1});
                    map.addOverlay(marker);
                    addClickHandler(content,marker);
                }
            }
        });
        setTimeout("pnRobRouteCounts()",3000);
    }
    var opts = {
        width : 20,     // 信息窗口宽度
        height: 10,     // 信息窗口高度
        title : "跑客信息" , // 信息窗口标题
        enableMessage:true//设置允许信息窗发送短息
    };
    function addClickHandler(content,marker){
        marker.addEventListener("click",function(e){
                    openInfo(content,e)}
        );
    }
    function openInfo(content,e){
        var p = e.target;
        var point = new BMap.Point(p.getPosition().lng, p.getPosition().lat);
        var infoWindow = new BMap.InfoWindow(content,opts);  // 创建信息窗口对象
        map.openInfoWindow(infoWindow,point); //开启信息窗口
    }

</script>
</body>
</html>